﻿Imports System.Data.SqlClient
Imports System.Data

Partial Class IntranetLogin
    Inherits System.Web.UI.Page

    Dim clsLogueoAdministrador As New LogueoAdministrador

    Protected Sub btnEntrarIntranet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEntrarIntranet.Click
        Dim validar As Boolean = validarLogueo()

        If validar = True Then
            Response.Redirect("intraInicio.aspx")

        End If

    End Sub

    Private Function validarLogueo() As Boolean
        Dim validar As Boolean = True

        If txtUsuario.Text = "" Then
            mostrarMensaje("Campo Usuario </br>        Requerido.")
            validar = False
        ElseIf txtContraseña.Text = "" Then
            mostrarMensaje("Campo Contraseña </br>        Requerido.")
            validar = False
        Else

            Dim variable As Integer = clsLogueoAdministrador.Logueo(txtUsuario.Text.ToUpper, txtContraseña.Text.ToUpper)

            If variable = 0 Then
                mostrarMensaje("Datos Incorrectos")
                validar = False

            End If

        End If
       
        Return validar

    End Function

    Sub mostrarMensaje(ByVal text As String)

        imgError.Visible = True
        lblError.Visible = True
        lblError.Text = text

    End Sub
End Class
